package com.hfh.io.exer;

import org.junit.Test;

import java.io.*;

public class Exer4 {
    //加密
    @Test
    public void test() throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("file/jpg/1.jpg"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("file/jpg/1_.jpg"));
        int data;
        while ((data=bis.read())!=-1){
            bos.write(data^5);
        }
        bos.flush();
        bos.close();
        bis.close();
    }

    //解密
    @Test
    public void test1() throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("file/jpg/1_.jpg"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("file/jpg/1_1.jpg"));
        int data;
        while ((data=bis.read())!=-1){
            bos.write(data^5);
        }
        bos.flush();
        bos.close();
        bis.close();
    }
}
